<script setup lang="ts">
import { ref } from 'vue'
import radioCell from '@/components/radio-cell.vue'

const emit = defineEmits(['close'])
const show = ref(false)
defineExpose({
  show,
})

const editRef = ref()
const formModel = ref({
  name: '123456',
  phone: '123453654321',
  UserPwdB: '',
  is_member: '1',
  single_login: '0', // 默认单一登录关闭
  is_tuik: '0', // 默认自动退款关闭
  login_way: 'is_account_login', // 默认密码登录
})

function handleSubmit() {
  editRef.value.validate().then(({ valid, errors }) => {
    if (valid) {
      console.log('表单验证通过')
      // 提交表单逻辑
      emit('close', false)
      show.value = false
    }
    else {
      console.log('表单验证不通过')
    }
  })
}
function handleClose() {
//   show.value = false

}
</script>

<template>
  <wd-popup v-model="show" lock-scroll position="bottom" :safe-area-inset-bottom="true" closable custom-style="height: 1000rpx;padding-bottom: 80rpx;overflow: hidden;border-radius: 32rpx 32rpx 0 0;" @close="handleClose">
    <view class="wot-form-title">
      【 商户＞信息修改 】
    </view>
    <scroll-view scroll-y>
      <wd-form ref="editRef" :model="formModel">
        <wd-cell-group border>
          <wd-input
            v-model="formModel.name"
            label="登录账号："
            label-width="100px"
            prop="name"
            clearable
            readonly
          />
          <wd-input
            v-model="formModel.phone"
            label="注册手机："
            label-width="100px"
            prop="phone"
            clearable
            readonly
          />
          <wd-input
            v-model="formModel.UserPwdB"
            label="登录密码："
            label-width="100px"
            prop="UserPwdB"
            clearable
            placeholder="请输入设备名称"
          />
          <radio-cell
            label-width="100px"
            title="会员开关："
          >
            <wd-radio-group
              v-model="formModel.is_member" shape="dot" inline
            >
              <wd-radio value="1">
                开启
              </wd-radio>
              <wd-radio value="2">
                关闭
              </wd-radio>
            </wd-radio-group>
          </radio-cell>
          <view class="wot-tips">
            会员系统打开后可购币多次玩
          </view>
          <radio-cell
            label-width="100px"
            title="自动退款："
          >
            <wd-radio-group
              v-model="formModel.is_tuik" shape="dot" inline
            >
              <wd-radio value="1">
                开启
              </wd-radio>
              <wd-radio value="2">
                关闭
              </wd-radio>
            </wd-radio-group>
          </radio-cell>
          <view class="wot-tips">
            关闭后由商户线下核对上币情况
          </view>
          <radio-cell
            label-width="100px"
            title="登录方式："
          >
            <wd-radio-group
              v-model="formModel.login_way" shape="dot" inline
            >
              <wd-radio value="is_account_login">
                密码登录
              </wd-radio>
              <wd-radio value="is_wechat_login">
                微信登录
              </wd-radio>
              <wd-radio value="is_sms_login">
                短信登录
              </wd-radio>
            </wd-radio-group>
          </radio-cell>
          <view class="wot-tips">
            未勾选的方式将不可登录
          </view>
          <radio-cell
            label-width="100px"
            title="单一登录："
          >
            <wd-radio-group
              v-model="formModel.single_login" shape="dot" inline
            >
              <wd-radio value="1">
                开启
              </wd-radio>
              <wd-radio value="0">
                关闭
              </wd-radio>
            </wd-radio-group>
          </radio-cell>
          <view class="wot-tips">
            开启后只允许一处登录
          </view>
        </wd-cell-group>

        <view class="btn-outer-pd">
          <wd-button type="primary" size="small" block @click="handleSubmit">
            保存修改
          </wd-button>
        </view>
      </wd-form>
    </scroll-view>
  </wd-popup>
</template>

<style lang="scss" scoped>
.desc{
    padding: 40rpx 20rpx;
    line-height: 40rpx;
    font-size: 24rpx;
    color: #ED6A0C;
}
</style>
